package demo2;

public class Main {
    public static void main(String[] args) {
        PersonDirector personDirector;
        PersonBuilder personBuilder1 = new ThinPersonBuilder();
        personDirector = new PersonDirector(personBuilder1);
        personDirector.CreatePerson();

        PersonBuilder personBuilder2 = new FatThinPersonBuilder();
        personDirector = new PersonDirector(personBuilder2);
        personDirector.CreatePerson();
    }
}

abstract class PersonBuilder{
    public abstract void BuildHead();
    public abstract void BuildNeck();
    public abstract void BuildHand();
    public abstract void BuildFoot();
    public abstract void BuildBody();
}

class ThinPersonBuilder extends PersonBuilder{
    @Override
    public void BuildHead() {
        System.out.println("构建小头");
    }

    @Override
    public void BuildNeck() {
        System.out.println("构建小脖子");
    }

    @Override
    public void BuildHand() {
        System.out.println("构建小手");
    }

    @Override
    public void BuildFoot() {
        System.out.println("构建小脚");
    }

    @Override
    public void BuildBody() {
        System.out.println("构建小身体");
    }
}


class FatThinPersonBuilder extends PersonBuilder{
    @Override
    public void BuildHead() {
        System.out.println("构建大头");
    }

    @Override
    public void BuildNeck() {
        System.out.println("构建大脖子");
    }

    @Override
    public void BuildHand() {
        System.out.println("构建大手");
    }

    @Override
    public void BuildFoot() {
        System.out.println("构建大脚");
    }

    @Override
    public void BuildBody() {
        System.out.println("构建大身体");
    }
}

class PersonDirector{
    private PersonBuilder personBuilder;
    public PersonDirector(PersonBuilder personBuilder){
        this.personBuilder = personBuilder;
    }

    public void CreatePerson(){
        System.out.println("====创建人====");
        personBuilder.BuildHead();
        personBuilder.BuildNeck();
        personBuilder.BuildBody();
        personBuilder.BuildHand();
        personBuilder.BuildFoot();
        System.out.println("====创建完毕====");
    }
}